<script src="/facturacion/assets/97dfa10c/jquery.js" type="text/javascript"></script>
<div class="row">
	<div class="span-4">
		<label>Comprobante</label>
		<input type="text"  disabled="disabled" value="<?php echo $movimiento->tComprobante0->descripcion; ?>" >
	</div>
	<div class="span-4">
		<label>Prefijo</label>
		<input type="text"  disabled="disabled" value="<?php echo $movimiento->pComprobante; ?>" >
	</div>
	<div class="span-4">
		<label>Numero</label>
		<input type="text"  disabled="disabled" value="<?php echo $movimiento->nComprobante; ?>" >
	</div>
	<div class="span-4">
		<label>Importe Total</label>
		<input type="text"  disabled="disabled" value="<?php echo "$ ".$movimiento->importe; ?>" >
	</div>
</div>
<hr>
<div class="span-16">
		<div class="span-13">
			<label>Cheques</label>
			<?php $cheques = Cheque::model()->findAll(array('condition'=>'saldado=0','order'=>'numero_comprobante'));?>
			<select id="cheques">
			<option value="">Asocie los cheques....</option>
				<?php foreach ($cheques as $cheque):?>
					<option value="<?php echo $cheque->idCheque; ?>"><?php echo $cheque->prefijo_comprobante."-".$cheque->numero_comprobante;?> ( <?php echo"$ ". $cheque->importe; ?> <?php echo $cheque->cliente0->nombre;?> )</option>
				<?php endforeach;?>
			</select>
		</div>
						<div class="span-2" style="margin-top: 20px; margin-left: 15px;">
					<a id="add_item" href="#"><?php echo CHtml::image(Yii::app()->request->baseUrl.'/images/add.png');?> </a>
				</div>
		<div class="span-17">
			<table id="table_cheques">
				<thead>
					<tr>
						<th>Id</th>
						<th>Descripci&oacute;n</th>
						<th>Eliminar</th>
					</tr>
				</thead>
				<tbody><tr></tr>
				</tbody>
			</table>
		</div>
	
</div>
<hr>
<div class="row">
<table>
	<thead>
		<tr>
			<th>Comprobante</th>
			<th>Prefijo</th>
			<th>Numero</th>
			<th>Deuda</th>
		</tr>
	</thead>
	<tbody>
		<?php foreach ($deudas as $row):?>
			<tr>
				<td><?php echo $row->tipoComprobante->descripcion;?></td>
				<td><?php echo $row->prefijo_comprobante;?></td>
				<td><?php echo $row->numero_comprobante;?></td>
				<td><?php echo $row->deuda;?></td>
			</tr>
		<?php endforeach;?>
	</tbody>
	
</table>
</div>
<!-- Logic  -->
<script type="text/javascript">
	$("#add_item").click(function(event){
		$item = $("#cheques option:selected");
		$row = "<tr><td>"+$item.val()+"</td><td>"+$item.text()+"</td><td><a href='#' onclick=eliminar_row(this)><img src='<?php echo Yii::app()->request->baseUrl;?>/images/remove.png'></a></td></tr>";
		$("#table_cheques tbody").append($row);
		$item.remove();
		event.preventDefault();
		});
	function eliminar_row(row){
		valor = $(row).closest('tr').find("td").eq(0);
		texto = $(row).closest('tr').find("td").eq(1);
		$("#cheques option:first").after("<option value='"+valor.text()+"'>"+texto.text()+"</option>");
		$(row).closest('tr').remove();
	}
</script>
<!-- End Logic -->
